import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JTextField;


public class GUI {

	private JFrame frame;
	private SmartSensorJavaClient controller;
	private JTextField textField;
	private JTextField textField_1;


	/**
	 * Create the application.
	 */
	public GUI(SmartSensorJavaClient controller) {
		this.controller = controller;
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	@SuppressWarnings("serial")
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 854, 743);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JTree tree = new JTree();
		tree.setBounds(0, 0, 141, 705);
		tree.setModel(new DefaultTreeModel(
			new DefaultMutableTreeNode("SmartSensor") {
				{
					add(new DefaultMutableTreeNode("Accelerometer"));
					add(new DefaultMutableTreeNode("Temperature"));
				}
			}
		));
		frame.getContentPane().add(tree);
		
		JPanel panel = new JPanel();
		panel.setBounds(148, 0, 690, 705);
		frame.getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel lblSensor = new JLabel("Sensor");
		lblSensor.setBounds(162, 5, 50, 14);
		panel.add(lblSensor);
		
		JLabel lblName = new JLabel("name");
		lblName.setBounds(208, 5, 69, 14);
		panel.add(lblName);
		
		JLabel lblValue = new JLabel("value");
		lblValue.setFont(new Font("Tahoma", Font.PLAIN, 38));
		lblValue.setBounds(163, 48, 94, 45);
		panel.add(lblValue);
		
		textField = new JTextField();
		textField.setBounds(369, 37, 86, 20);
		panel.add(textField);
		textField.setColumns(10);
		
		textField_1 = new JTextField();
		textField_1.setBounds(369, 84, 86, 20);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		JMenuBar menuBar = new JMenuBar();
		frame.setJMenuBar(menuBar);
		
		JMenu mnConnect = new JMenu("Arduino");
		menuBar.add(mnConnect);
		
		JMenuItem mntmReconnect = new JMenuItem("Reconnect");
		mnConnect.add(mntmReconnect);
		mnConnect.addMenuListener(controller);
	}
	
	public JFrame getFrame() {
		return frame;
	}
}
